{% extends 'base.html'%}

{% block contennt %}
<div class="cl-cantainer container">
    <div class="row">
        <div class="col-md-9 cl-left">
            <div class="recommend-top">
                <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                        <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                        <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                        <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
                    </ol>
                     <div class="carousel-inner">
                            <div class="carousel-item active">
                                <img class="d-block w-100" src="../static/img/01f2675c4925d3a801203d22edcf7e.jpg@1280w_1l_2o_100sh.jpg" alt="First slide">
                            </div>
                            <div class="carousel-item">
                                <img class="d-block w-100" src="../static/img/316-1F6021J102-50.jpg" alt="Second slide">
                            </div>
                            <div class="carousel-item">
                                <img class="d-block w-100" src="../static/img/thumb-1920-1077942.jpg" alt="Third slide">
                            </div>
                        </div>
                    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>
                </div>
            </div>
            <div class="recommend-bottom">
                {% for article in art %}
                <div class="recommend-item">
                    <a href="{% url 'home:details' %}?artid={{article.id}}"><img src="{{ article.avatar.url }}" class="img-fluid" alt=""></a>
                </div>
                 {% endfor %}
            </div>
            <div>
                {% for article in articles %}
                <div class="cl-card">
                    <div class="row">
                        <div class="col-lg-3 col-md-4 col-sm-12 cl-card-image"><a href="{% url 'home:details' %}?artid={{article.id}}"><img
                                src="{{ article.avatar.url }}" class="img-fluid" alt=""></a>
                        </div>
                        <div class="col-lg-9 col-md-8 col-sm-12 cl-card-main">
                            <h3 class="cl-card-main-title"><a
                                    href="{% url 'home:details' %}?artid={{article.id}}">{{ article.tags }}</a>
                            </h3>
                            <p class="cl-card-main-info">
                                {{ article.sumary }}
                            </p>
                            <p class="cl-card-more"><a href="{% url 'home:details'%}?artid={{article.id}}">阅读更多...</a></p>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
        </div>
        <div class="col-md-3 cl-right">
            <div class="right-card">
                <div class="right-card-main">
                    <div class="right-card-title">故事推荐</div>
                    <div class="cl-code">
                        <img src="../static/img/img.png" class="img-fluid" alt="">
                        <p>关注作者获取更多模板信息，定时发布干货文章</p>
                    </div>
                </div>
            </div>
            <div class="right-card">
                <div class="right-card-main">
                    <div class="right-card-title">最新文章</div>
                    <div class="right-recommended"><a href="#"><img src="../static/img/v2-c32824ac8a792f084e9ca7a9b6345932_r.jpg" class="img-fluid" alt=""></a></div>
                        <ul class="right-recommended-list">
                            {% for foo in articles %}
                                <li><a href="details.html">
                                <i class="fa fa-angle-right" aria-hidden="true">
                                </i>{{ foo.tags }}</a>
                            {% endfor %}
                        </ul>
                </div>
            </div>
            <div class="right-card">
                <div class="right-card-main">
                    <div class="right-card-title">热门标签</div>
                    <ul class="label">
                        <li><a href="#">战争</a></li>
                        <li><a href="#">文化</a></li>
                        <li><a href="#">其他</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
        <nav aria-label="Page navigation example">
            <ul class="pagination justify-content-center">
                {# has_previous True如果有上一页，则返回#}
                    {% if articles.has_previous %}
                        <li class="page-item">
                            <a class="page-link"
                               href="?cat_id={{ cat_id }}&page_index={{ articles.previous_page_number }}"
                               aria-label="Previous">
                                <span aria-hidden="true">上一页</span>
                                <span class="sr-only">上一页</span>
                            </a>
                        </li>
                    {% else %}
                    <li class="page-item disabled">
                        <a class="page-link" href="#" aria-label="Previous">
                            <span aria-hidden="true">上一页</span>
                            <span class="sr-only">上一页</span>
                        </a>
                    </li>
                {% endif %}
                {#  articles.paginator.page_range  返回当前数据的 页码迭代器。 #}
                {% for num in articles.paginator.page_range %}
                    {% if num %}
                        {% ifequal num articles.number %}
                            <li class="page-item active"><a class="page-link" href="#">{{ num }}</a></li>
                        {% else %}
                            <li class="page-item"><a class="page-link"
                                                     href="?cat_id={{ cat_id }}&page_index={{ num }}">{{ num }}</a>
                            </li>
                        {% endifequal %}
                    {% else %}
                        <li class="disabled"><a href="#">...</a></li>
                    {% endif %}
                {% endfor %}
                {# has_next True如果有下一页则返回#}
                {% if articles.has_next %}
                    <li class="page-item">
                        <a class="page-link"
                           href="?cat_id={{ cat_id }}&page_index={{ articles.next_page_number }}"
                           aria-label="Next">
                            <span aria-hidden="true">下一页</span>
                            <span class="sr-only">下一页</span>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <a class="page-link" href="#" aria-label="Next">
                            <span aria-hidden="true">下一页</span>
                            <span class="sr-only">下一页</span>
                        </a>
                    </li>
                {% endif %}
                <li class="page-item disabled">
                    <a href="#" class="page-link">共计：{{ articles.paginator.count }} 条</a>
                </li>
            </ul>
        </nav>


{% endblock %}
